#! /home/lyh/anaconda3/envs/pytorch1.6/bin/python3.8
import torch
import cv2 as cv
import numpy as np

# 加载图像
image = cv.imread('/home/lyh/yolov5/datasets/Garbage_sorting_data/test/card_004.jpg',1)
# yolo目录
yolo_path = '/home/lyh/yolov5/yolov5'
# 权重文件目录
weight_path = '/home/lyh/yolov5/yolov5/runs/train/exp24/weights/best.pt'
# 置信度
conf = 0.65
model = torch.hub.load(yolo_path, 'custom', path=weight_path, source='local')
model.conf =conf
# 颜色通道转换
results = model(cv.cvtColor(image, cv.COLOR_RGB2BGR))
print('--------------------------------------------------------------------')
print(results.pandas().xyxy)


